package com.zqf.shiro.filter;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.apache.shiro.authc.AuthenticationToken;

;

/**
 * @author zqf
 * @date 11/27/2018
 */
@Api("JwtToken")
public class JwtToken implements AuthenticationToken {

    @ApiModelProperty("访问用token")
    private String accessToken;
    @ApiModelProperty("刷新用token")
    private String refreshToken;
    @ApiModelProperty("token类型")
    private String tokenType;
    @ApiModelProperty("过期时间")
    private long expiresIn;

    public JwtToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public JwtToken(String accessToken, String refreshToken) {
        this.accessToken = accessToken;
        this.refreshToken = refreshToken;
    }

    public JwtToken(String accessToken, String refreshToken, String tokenType, long expiresIn) {
        this.accessToken = accessToken;
        this.refreshToken = refreshToken;
        this.tokenType = tokenType;
        this.expiresIn = expiresIn;
    }

    @JsonIgnore
    @Override
    public Object getPrincipal() {
        return accessToken;
    }

    @JsonIgnore
    @Override
    public Object getCredentials() {
        return accessToken;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public String getRefreshToken() {
        return refreshToken;
    }

    public void setRefreshToken(String refreshToken) {
        this.refreshToken = refreshToken;
    }

    public String getTokenType() {
        return tokenType;
    }

    public void setTokenType(String tokenType) {
        this.tokenType = tokenType;
    }

    public long getExpiresIn() {
        return expiresIn;
    }

    public void setExpiresIn(long expiresIn) {
        this.expiresIn = expiresIn;
    }
}


